<item name="Unpublish Item and Delete" key="unpublish item and delete" id="{2C83F71E-01A6-41E3-A4C1-C1C89E72325A}" tid="{DD22F1B3-BD87-4DB2-9E7D-F7A496888D43}" mid="{00000000-0000-0000-0000-000000000000}" sortorder="300" language="en" version="1" template="powershell script" parentid="{EFF950FC-E776-43C7-9337-E649B2085DEC}" created="20190909T125321Z"><fields><field tfid="{5DD74568-4D4B-44C1-B513-0AF5F4CDA34F}" key="__created by" type="Single-Line Text"><content>sitecore\ramkumarAdmin</content></field><field tfid="{BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}" key="__updated by" type="Single-Line Text"><content>sitecore\ramkumarAdmin</content></field><field tfid="{8CDC337E-A112-42FB-BBB4-4143751E123F}" key="__revision" type="Single-Line Text"><content>1220339a-af92-4169-86d1-c437733ae492</content></field><field tfid="{001DD393-96C5-490B-924A-B0F25CD9EFD8}" key="__lock" type="Multi-Line Text"><content>&lt;r /&gt;</content></field><field tfid="{25BED78C-4957-4165-998A-CA1B52F67497}" key="__created" type="datetime"><content>20190909T125321Z</content></field><field tfid="{52807595-0F8F-4B20-8D2A-CB71D28C6103}" key="__owner" type="Single-Line Text"><content>sitecore\ramkumarAdmin</content></field><field tfid="{D9CF14B1-FA16-4BA6-9288-E8A174D4D522}" key="__updated" type="datetime"><content>20190912T125233Z</content></field><field tfid="{06D5295C-ED2F-4A54-9BF2-26228D113318}" key="__icon" type="Icon"><content>Applications/32x32/error.png</content></field><field tfid="{B1A94FF0-6897-47C0-9C51-AA6ACB80B1F0}" key="script" type="Multi-Line Text"><content>

#Getting selected Item
$sourceItem = Get-Item .

$displayMsg = "Are You Sure you want to Un-Publish and Delete  '" + $sourceItem.Name + "' Item ?"

#Confirmation Dialog with Ok / Cancel Button
$ReturnValue = Show-Confirm -Title $displayMsg

function RunScript
{
    #Making item unpublishable 
    $sourceItem.Editing.BeginEdit();
    $sourceItem.Fields["__Never publish"].Value = "1";
    $sourceItem.Editing.EndEdit();
    
    #publishing item to web db in all languages - You can update desired target, language and publishing type below
    Publish-Item $sourceItem -Target "web" -Language * -PublishMode Smart 
    
    #Removing the Item
    $sourceItem | Remove-Item
}


#If Ok button is chosen it returns 'yes' which in turn runs the below script
if($ReturnValue -eq 'yes'){
    $items = RunScript
    $displayMsg =  $sourceItem.Name + " Item has been Unpublished and Deleted !"
    Show-Alert -Title $displayMsg
}



</content></field></fields></item>